package com.yj.netty.chapter01;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class MyClientInitializer extends ChannelInboundHandlerAdapter {

    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        ctx.channel().writeAndFlush(Unpooled.copiedBuffer("Hello World".getBytes()));
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        //try {
        //    String received = (String) msg;
        //    System.out.println("Received from server: " + received);
        //} finally {
        //    ReferenceCountUtil.release(msg); // 释放消息资源
        //}
    }
}
